package dao.server;

import java.net.InetAddress;
import java.sql.SQLException;

import account.model.Account;
import dao.DataConnection;

public class DataLoadIP extends DataConnection{
	
	private static DataLoadIP instance;
	
	private String ip;
	
	public static DataLoadIP getInstance() {
		if (instance == null) {
			instance = new DataLoadIP();
		}
		return instance;
	}
	
	//server ip uit database laden
	public String LoadServerIP(){
		String sql = "SELECT ip_address, naam FROM server WHERE id = '1'";
		
		try{
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql); 
			Account acc;	

			//geef local ip aan accounts mee
			while(rs.next()){									
				acc = new Account();
				ip = acc.setServer_ip(rs.getString("ip_address"));
			}	
		}
		catch(SQLException sqle){
			sqle.printStackTrace();
		}
		return ip;
	}
	
	//TODO Vul hier het IP adres van de server in
	//dit moet automatisch worden met de methode hierboven beschreven
	public String LoadIP(){
		openConn();
		ip = "172.16.66.41";
//		LoadServerIP();
		closeConn();
		
		return ip;
	}

}
